package builder_pattern.type2;

import builder_pattern.type2.hero.*;

public class Hero {

    private String name;

    private Profession profession;

    private Armor armor;

    private HairColor hairColor;

    private HairType hairType;

    private Weapon weapon;

    public static class Builder {
        private String name;

        private Profession profession;

        private Armor armor;

        private HairColor hairColor;

        private HairType hairType;

        private Weapon weapon;

        public Builder(String name, Profession profession) {
            this.name = name;
            this.profession = profession;
        }

        public Builder withArmor(Armor armor) {
            this.armor = armor;
            return this;
        }

        public Builder withHairColor(HairColor hairColor) {
            this.hairColor = hairColor;
            return this;
        }

        public Builder withHairType(HairType hairType) {
            this.hairType = hairType;
            return this;
        }

        public Builder withWeapon(Weapon weapon) {
            this.weapon = weapon;
            return this;
        }

        public Hero build() {
            return new Hero(this);
        }
    }

    private Hero(Builder builder) {
        this.name = builder.name;
        this.profession = builder.profession;
        this.armor = builder.armor;
        this.hairColor = builder.hairColor;
        this.hairType = builder.hairType;
        this.weapon = builder.weapon;
    }

    @Override
    public String toString() {
        return "Hero{" +
                "name='" + name + '\'' +
                ", profession=" + profession +
                ", armor=" + armor +
                ", hairColor=" + hairColor +
                ", hairType=" + hairType +
                ", weapon=" + weapon +
                '}';
    }
}
